import store from '@/store'
const files = require.context('@/views/website', true, /\.vue$/)
let routes = [],
  pageList = []
files.keys().forEach((key, index) => {
  let page = files(key).default //vue页面对象
  let showName = page.showName //菜单名称
  let page_path = files.resolve(files.keys()[index]) //vue文件相当于整个项目的路径
  let route_path = page_path.replace(/\.\/src|\.vue/g, '') //页面路由路径
  if (page) {
    pageList.push({
      path: route_path,
      showName,
      name: page.name ? page.name : page_path.replace(/\.\/src\/views\/|\.vue/g, '').replace(/\//g, '-')
    })
  }
})
store.commit('setPageList', pageList)
export default routes
